package com.yj.ccs.abs.boot.pagination;

import org.apache.ibatis.reflection.factory.DefaultObjectFactory;

import java.util.Collection;

/**
 * Copyright 2017 (C) Yunjian-VC
 * Created on : 2017/12/8
 * Author     : Unbelievable9
 **/
public class CustomObjectFactory extends DefaultObjectFactory {

    @Override
    public <T> boolean isCollection(Class<T> type) {
        return Collection.class.isAssignableFrom(type) || Page.class == type;
    }

    @Override
    public <T> T create(Class<T> type) {
        if (Page.class == type) {
            return (T) Page.createInstance();
        }

        return super.create(type, null, null);
    }
}
